How do I select a field/column from the output of `ls -l`?

Posted by soandos on Ask Ubuntu See other posts from Ask Ubuntu or by soandos
Published on 2012-07-10T01:00:52Z Indexed on 2012/07/10 3:22 UTC
Read the original article Hit count: 239

Filed under:
|

My goal is deceptively simple (at least to me). I wish to take the output of ls -l or ls -lh and select just one field.

I am looking for this to be as bulletproof as possible, by which I mean, assume that filenames can have a variable number of spaces, not everything in the field has the same length, etc.

Bonus points for having a script that will take the name of the the field (or even just a field number), and then return the contents of the field.

I want to turn

enter image description here

into:

enter image description here

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about bash